<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
<!--    <search :config='searchConfig' @getHeight='getHeight' @search='search' />-->
    <!-- table区域-begin -->
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        v-bind='vexConfig'
        :align='left'
        :border='true'
        :checkbox-config="checkboxConfig"
        :columns='columns'
        :data='dataSource'
        :height='pageHeight-seachHeight-94'
        :loading='loading'
        :resizable='true'
        :showOverflow='true'
        :toolbar-config="tableToolbar"
        size='mini'
        @checkbox-change='selectChangeEvent'
        @checkbox-all="selectChangeEvent"
      >
        <!-- 按钮区域 -->
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button type="primary" @click="handleActModal">添加门店</a-button>
            <a-button type='primary' @click="downExportXls('competing_service')">导出</a-button>
          </div>
        </template>
<!--        <template  #action='{ row,rowIndex }'>-->
<!--          <a v-has="'getGoodsAdress:update'" @click='handleDelete(row)'>删除</a>-->
<!--        </template>-->
        <template #update='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #pager>
          <vxe-pager
            :currentPage.sync='ipagination.current'
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :page-size.sync='ipagination.pageSize'
            :pageSizes='ipagination.pageSizeOptions'
            :total='ipagination.total'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <act-term-modal  ref="ActTermModal"
                     modal-width="90%"
                     @ok="handelSaveWhite" />
  </a-card>
</template>

<script>
import { PageListMixin } from '@/mixins/PageListMixin'
import ActTermModal from '@views/tpm/act/modules/ActTermModal'
import { postAction } from '@api/manage'

export default {
  name: 'TpmActSpecialDetailList',
  mixins: [PageListMixin],
  props:["tempUuid"],
  components: {
    ActTermModal,
  },
  data() {
    return {
      description: '专项活动明细管理页面',
      //查询区域
      // searchConfig: [
      //   {
      //     type: 'input',
      //     name: 'code',
      //     placeholder: '门店编码'
      //   },
      //   {
      //     type: 'input',
      //     name: 'name',
      //     placeholder: '门店名称'
      //   },
      //   {
      //     type: 'input',
      //     name: 'custCode',
      //     placeholder: '经销商编码'
      //   },
      //   {
      //     type: 'input',
      //     name: 'custName',
      //     placeholder: '经销商名称'
      //   },
      //   {
      //     type: 'input',
      //     name: 'dqOrgName',
      //     placeholder: '省'
      //   },
      //   {
      //     type: 'input',
      //     name: 'provinceOrgName',
      //     placeholder: '市'
      //   },
      //   {
      //     type: 'input',
      //     name: 'cityOrgName',
      //     placeholder: '区'
      //   },
      // ],
      // 表头
      columns: [
        {
          width:50,
          type:'checkbox',
        },
        {
          title: '门店编码',
          align: 'center',
          field: 'terminalCode'
        },
        {
          title: '门店名称',
          align: 'center',
          field: 'terminalName'
        },
        {
          title: '省',
          align: 'center',
          field: 'province'
        },
        {
          title: '市',
          align: 'center',
          field: 'city'
        },
        {
          title: '区',
          align: 'center',
          field: 'area'
        },
        // {
        //   title: '操作',
        //   field: 'action',
        //   align: 'center',
        //   slots: { default: 'action' }
        // },
      ],
      dataSource:[],
      url: {
        // list:  window._CONFIG['domianTpmURL']+'/act/tpmActSpecialDetail/findPageList',
        delete:  window._CONFIG['domianTpmURL']+'/act/tpmActSpecialDetail/delete',
        deleteBatch: window._CONFIG['domianTpmURL']+'/act/tpmActSpecialDetail/deleteBatch',
      }
    }
  },
  created() {
    this.queryParam.tempUuid = this.tempUuid
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    handelSaveWhite(terms) {
      console.log(terms)
      this.dataSource = terms
      this.$emit('ok', this.dataSource);
      const record = { tempUuid: this.tempUuid }
      // record.details = terms
      // console.log(record)
      // var that = this
      // postAction(window._CONFIG['domianTpmURL'] + '/act/tpmActSpecialDetail/saveOrUpdate', record).then(async (res) => {
      //   if (res.success) {
      //     that.$message.success(res.message)
      //     await this.loadData()
      //     this.$refs.ActTermModal.close()
      //   } else {
      //     this.$message.warning(res.message)
      //   }
      // }).finally(() => {
      //   this.$refs.ActTermModal.confirmLoading = false
      // })
    },
    async handleActModal(record) {
      this.$refs.ActTermModal.showModal(this.tempUuid)
      this.$refs.ActTermModal.selectData = this.dataSource
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>